using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XQ.RequestOfficeSupplies.BLL.Common;
using XQ.RequestOfficeSupplies.DAL.DAL.Business;
using XQ.RequestOfficeSupplies.DAL.Model.Business;
using XQ.RequestOfficeSupplies.DAL.Model;
using XQ.RequestOfficeSupplies.DAL.Models;
using XQ.RequestOfficeSupplies.DAL;

namespace XQ.RequestOfficeSupplies.BLL.Business
{
    public class ApplicationFormOfficeSuppliesBLL
    {
        ApplicationFormOfficeSuppliesDal applicationFormOfficeSuppliesDal = new ApplicationFormOfficeSuppliesDal();

        public List<ApplicationFormOfficeSuppliesReturnModel> GetList(ApplicationFormOfficeSuppliesSearchModel ssm, Pagination page, TokenModel token)
        {
            return applicationFormOfficeSuppliesDal.GetList(ssm, page, token);
        }

        public Guid SaveApplicationFormOfficeSupplies(ApplicationForm_OfficeSupplies applicationForm_OfficeSupplies, TokenModel token)
        {
            Guid applicationFormOfficeSuppliesID = applicationForm_OfficeSupplies.id;
            bool isSuccess = false;
            DateTime curTime = DateTime.Now;
            if (applicationForm_OfficeSupplies != null)
            {
                //修改
                isSuccess = applicationFormOfficeSuppliesDal.UpdateModel(applicationForm_OfficeSupplies) > 0;

            }
            else
            {
                //新增
                ApplicationForm_OfficeSupplies applicationFormOfficeSuppliesInfo = applicationFormOfficeSuppliesDal.AddModel(applicationForm_OfficeSupplies);
                applicationFormOfficeSuppliesID = applicationFormOfficeSuppliesInfo.id;

            }

            return applicationFormOfficeSuppliesID;
        }

        public ApplicationFormOfficeSuppliesReturnModel GetApplicationFormOfficeSuppliesByID(Guid id)
        {
            ApplicationFormOfficeSuppliesReturnModel applicationFormOfficeSuppliesModel = new ApplicationFormOfficeSuppliesReturnModel();
            ApplicationForm_OfficeSupplies applicationFormOfficeSupplies = applicationFormOfficeSuppliesDal.FindModel(c => c.id == id);
            applicationFormOfficeSuppliesModel = ClassHelper.ParentCopyToChild<ApplicationForm_OfficeSupplies, ApplicationFormOfficeSuppliesReturnModel>(applicationFormOfficeSupplies);

            return applicationFormOfficeSuppliesModel;
        }


        public int DeleteByIds(List<Guid> ids)
        {
            return applicationFormOfficeSuppliesDal.DeleteModel(c => ids.Contains(c.id));
        }
    }
}
